Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit bb2897445f3a2bba4b943557241b29e37b8b6954


Parents : 406b141
Author : Mark Qvist <bc7291552be7a58f361522990465165c>
Signature : T66BB85Valid, signed by author
Date : 2026-07-16T15:18:08+02:00

Added RESOURCE_RCL signal on resource receiver cancel. Improved link identify and resource safeguards.

Changes

2 files changed, 13 insertions(+), 7 deletions(-)

M RNS/Link.py +6 -4

Diff

diff --git a/RNS/Link.py b/RNS/Link.py
index 90812086b..7116c7eae 100644
--- a/RNS/Link.py
+++ b/RNS/Link.py
@@ -664,6 +664,7 @@ class Link:
Closes the link and purges encryption keys. New keys will
be used if a new link to the same destination is established.
"""
+ if self.status == Link.CLOSED: return
if self.status != Link.PENDING and self.status != Link.CLOSED: self.__teardown_packet()
self.status = Link.CLOSED
if self.initiator: self.teardown_reason = Link.INITIATOR_CLOSED
@@ -968,10 +969,11 @@ class Link:
self.teardown()
else:
- self.__remote_identity = identity
- if self.callbacks.remote_identified != None:
- try: self.callbacks.remote_identified(self, self.__remote_identity)
- except Exception as e: RNS.log(f"Error while executing remote identified callback from {self}. The contained exception was: "+str(e), RNS.LOG_ERROR)
+ if self.__remote_identity == None:
+ self.__remote_identity = identity
+ if self.callbacks.remote_identified != None:
+ try: self.callbacks.remote_identified(self, self.__remote_identity)
+ except Exception as e: RNS.log(f"Error while executing remote identified callback from {self}. The contained exception was: "+str(e), RNS.LOG_ERROR)
self.__update_phy_stats(packet, query_shared=True)

diff --git a/RNS/Resource.py b/RNS/Resource.py
index 6de1ec998..eff056290 100644
--- a/RNS/Resource.py
+++ b/RNS/Resource.py
@@ -149,7 +149,7 @@ class Resource:
COMPLETE = 0x06
FAILED = 0x07
CORRUPT = 0x08
- REJECTED = 0x00
+ REJECTED = 0x09
@staticmethod
def reject(advertisement_packet):
@@ -1090,10 +1090,14 @@ class Resource:
try:
cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_ICL)
cancel_packet.send()
- except Exception as e:
- RNS.log("Could not send resource cancel packet, the contained exception was: "+str(e), RNS.LOG_ERROR)
+ except Exception as e: RNS.log("Could not send resource cancel packet, the contained exception was: "+str(e), RNS.LOG_ERROR)
self.link.cancel_outgoing_resource(self)
else:
+ if self.link.status == RNS.Link.ACTIVE:
+ try:
+ cancel_packet = RNS.Packet(self.link, self.hash, context=RNS.Packet.RESOURCE_RCL)
+ cancel_packet.send()
+ except Exception as e: RNS.log("Could not send resource cancel packet, the contained exception was: "+str(e), RNS.LOG_ERROR)
self.link.cancel_incoming_resource(self)
if self.callback != None:


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────